package projet_v1.basics;
import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import projet_v1.Actor;
import projet_v1.Breed;
import projet_v1.Human;
import projet_v1.Zombie;
import projet_v1.simulation.Field;
import projet_v1.simulation.Location;

/**
 * Test class of Zombie class.
 * @author Antoine Lavail
 *
 */
public class TestZombie {
    
    Zombie zombie1;

    /**
     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {
        zombie1 = new Zombie(40, new Field(30,30), new Location(15,15));
    }

    /**
     * Test method for {@link projet_v1.Zombie#encounterCharacter(projet_v1.Character)}.
     */
    @Test(expected=NullPointerException.class)
    public void testEncounterCharacter() {
        Human h = new Human(100);
        
        zombie1.encounterCharacter(h);
        assertEquals(100 - 35, h.getHealthPoints());
        assertEquals(Breed.ZOMBIE, h.getLastAttackedBy());
        
        // NullPointerException
        zombie1.encounterCharacter(null);
    }

    /**
     * Test method for {@link projet_v1.Zombie#act(projet_v1.simulation.Field, projet_v1.simulation.Field, java.util.List)}.
     */
    @Test(expected=NullPointerException.class)
    public void testAct() {
        
        Field currentField = new Field(30,30);
        Field updatedField = new Field(30,30);
        
        Human h = new Human(50, new Field(30,30), new Location(14,15));
        currentField.place(zombie1, new Location(15,15));
        currentField.place(h, new Location(14,15));
        updatedField.place(h, new Location(14,15));
        updatedField.place(zombie1, new Location(15,15));
        
        zombie1.act(currentField, updatedField, new ArrayList<Actor>());
        
        assertEquals(50-35, h.getHealthPoints());
        assertEquals(Breed.ZOMBIE, h.getLastAttackedBy());
        
        // NullPointerException's
        zombie1.act(null, new Field(20,20), new ArrayList<Actor>());
        zombie1.act(new Field(20,20), null, new ArrayList<Actor>());
    }
}
